<!--动态表单《表头和表尾》搜索组建-->
<template>
    <div class="all-search-wrapper" :id="boxId" ref="searchInput">
        <a-input :class="[dynamicData.val=='departmentstaff'?'inputClass':'']" ref="inputRef" :placeholder="`请选择${dynamicData.name}`" v-model="inputValue" @focus="showModal" @change="inputSearch" @pressEnter="clickEnter" />
        <div class="search-wrapper" ref="searchWrapper" v-show="tableShow" :style="columns.length<=2?{'width': '350px'}:''">
            <a-table :scroll="{x:300,y:200}" :columns="columns" :data-source="tableData" :customRow="customClick" bordered :pagination="pagination" :loading="isRun">
                <!--建议供应商-->
                <span slot="supplieType" slot-scope="text">
                    {{text==1?'客户':text==2?'供应商':'客户/供应商'}}
                </span>
                <template slot="officeName" slot-scope="text,record">
                    <div :style="record.parentId?{'margin-left':'10px'} : ''">
                        {{text}}
                    </div>
                </template>
            </a-table>
        </div>
    </div>
</template>
<script>

import { getAction, postAction } from "@/api/manage";
import { officeUserListToTree,searchInTreeData } from "@/utils/tree";

export default {
    data () {
        return {
        }
    },
    props: {
        dynamicData: {
            type: Array,
            default: () => []
        },
        changeInvoiceType: { //用于采购发票（发票搜索type:1正发票，0负发票）
            type: Number
        }
    },
    watch: {
        dynamicData: {
            handler (newName, oldName) {
                this.inputValue = this.dynamicData.value;
                if ('officeId' in this.dynamicData) {
                    let id = JSON.parse(JSON.stringify(this.dynamicData.officeId));
                    let name = JSON.parse(JSON.stringify(this.dynamicData.name));
                    this.postData.officeId = id;
                    this.postData.name = name;
                }
            },
            deep: true
        },
    },
    data () {
        return {
            boxId: null,             //当前容器id
            codesName: null,         //当前组建名称
            columns: [],

            pagination: {
                current: 1,
                pageSize: 5,
                total: 0,
                size: 'small',
                onChange: (page, pageSize) => {
                    this.pagination.current = page;
                    this.pagination.pageSize = pageSize;
                    this.pageList();
                }
            },
            postData: {},
            tableData: [],
            customClick: (record, index) => ({
                on: {
                    click: (event) => {
                        event.preventDefault();
                        this.clickEnter('click', record);

                    },
                },
            }),
            tableShow: false,
            isRun: false,
            setTime: null,  //延迟请求
            id: null,       //当前选择的搜索id
            tableBody: null,
            apiUrl: null,
            inputValue: '',  //输入框的值
        }
    },
    created () {
        this.checkSearch();

        if (this.$route.path == '/inventory/bills/InitialInventory') {
            this.pageList('warehouse');
        }
        

        //发票
        if (this.$route.path == '/procurement/purchaseInvoice') {
            this.pageList('invoice');
        }

        if (this.$route.path == '/procurement/productionDemand') {
            this.pageList('invoice');
        }
    },
    mounted () {
        document.addEventListener('click', (e) => {
            //获取弹出表格对象
            if (this.tableShow && this.boxId != null) {
                const userCon = document.getElementById(this.boxId);

                //判断表格对象中是否包含点击对象
                if (userCon && !userCon.contains(e.target)) {

                    //删除操作
                    if (this.inputValue == '') {
                        console.log(this.codesName)
                        let data = Object.assign({}, { codesName: this.codesName })
                        this.$emit('clickItem', data);
                    } else {
                        if (this.id) {
                            let data = this.tableData.filter(item => item.id == this.id);
                            this.inputValue = data[0].name;
                        }
                    }
                    this.tableShow = false
                }
            }

        })
        var _this = this;
        window.onresize = () => {
            _this.tableShow = false
        }

        // 判断table的滚动条是否到达底部
        // this.tableBody = document.getElementById(this.boxId).getElementsByClassName('ant-table-body');
        // this.tableBody[0].onscroll = function () {
        //     // scrollTop + clientHeight == scrollHeight
        //     //  scrollTop为滚动条在Y轴上的滚动距离。
        //     // clientHeight为内容可视区域的高度。
        //     // scrollHeight为内容可视区域的高度加上溢出（滚动）的距离。
        //     if (_this.tableBody[0].scrollTop + _this.tableBody[0].clientHeight == _this.tableBody[0].scrollHeight) {
        //         console.log('我到底部了')
        //         // _this.pagination.current++;
        //         // _this.pageList();
        //     }
        // }
    },
    methods: {
        pageList (defaultRun) {
            if (!this.isRun) {
                this.isRun = true;
                if (defaultRun == 'warehouse') {
                    this.apiUrl = '/in/warehouse/pageList';
                    this.columns = [
                        { title: "仓库编码", dataIndex: "whCode" },
                        { title: "仓库名称", dataIndex: "whName", ellipsis: true, },
                        { title: "负责人", dataIndex: "whPerson", ellipsis: true, },
                        { title: "电话", dataIndex: "whTelephone", ellipsis: true, },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        keyWord: this.inputValue,
                    }
                } else {
                    this.postData.current = this.pagination.current
                    this.postData.size = this.pagination.pageSize
                    this.postData['page.current'] = this.pagination.current
                    this.postData['page.size'] = this.pagination.pageSize
                }
                if (this.$route.path == '/production/productionPlan') {
                    this.apiUrl = '/sysUser/user/page'
                    this.columns = [
                        { title: "所属机构", dataIndex: "officeName", ellipsis: true, scopedSlots: { customRender: "officeName" }, },
                        { title: "姓名", dataIndex: "realName" }
                    ];
                }
                if (this.$route.path == '/production/productionDemand') {
                    this.apiUrl = '/mrp/getProgrammeList'
                    this.columns = [
                        { title: "方案代码", dataIndex: "code", ellipsis: true, scopedSlots: { customRender: "officeName" }, },
                        { title: "方案名称", dataIndex: "name" }
                    ];
                }
                if(this.dynamicData.code == "createUserId" && this.$route.path == '/production/management/productionOrder'){
                    this.apiUrl = 'system/office/getOfficeTreeDataList?isLoadUser=2'
                    this.columns = [
                        { title: "姓名", dataIndex: "name" }
                    ];
                }
                getAction(this.apiUrl, this.postData).then(response => {
                    
                    if (response.code === 200) {
                        if (this.dynamicData.val == 'inventoryCategory') {//存货分类 没有分页
                            let data = response.data;
                            data.forEach(element => {
                                this.$set(element, 'name', element.treeNames);
                            });
                            let recData = data.map(v => {
                                return { ...v, key: v.id }
                            })
                            this.tableData = recData;
                        } else if (this.dynamicData.val == 'contractType' || this.dynamicData.val == 'stageGroup') {//合同类别，合同阶段组 没有分页
                            let data = response.data;
                            let recData = data.map(v => {
                                return { ...v, key: v.id }
                            })
                            this.tableData = recData;
                        } else {
                            const { total, current, size } = response.data;
                            let page = {
                                total: total,
                                pageSize: size,
                                current: current
                            }
                            this.pagination = Object.assign(this.pagination, page);
                            let records = []
                            if(!response.data.records){
                                records = response.data.map(v => {
                                    return { ...v, key: v.id }
                                })
                            } else {
                                records = response.data.records.map(v => {
                                    return { ...v, key: v.id }
                                })
                            }
                            
                            //返回值处理
                            let val = this.dynamicData.val;
                            if (this.$route.path == '/production/productionPlan') {
                                val = 'productionPlan'
                            }
                            switch (val) {
                                case 'productionPlan':// 计划人和关闭人
                                    records.forEach(element => {
                                        this.$set(element, 'name', element.realName);
                                    });
                                    break;
                                case 'departmentstaff'://负责人
                                    records.forEach(element => {
                                        this.$set(element, 'name', element.empName);
                                    });
                                    break;
                                case 'employees'://业务员
                                    records.forEach(element => {
                                        this.$set(element, 'name', element.realName);
                                    });
                                    break;
                                case 'office'://部门
                                    records.forEach(element => {
                                        this.$set(element, 'name', element.officeName);
                                    });
                                    break;
                                case 'crm'://客户名称
                                    records.forEach(element => {
                                        this.$set(element, 'name', element.officeName);
                                    });
                                case 'supplie'://供应商
                                case 'contacts'://往来单位
                                    records.forEach(element => {
                                        this.$set(element, 'name', element.crmName);
                                    });
                                    break;
                                case 'crmCustomer'://报价单客户名称
                                    records.forEach(element => {
                                        this.$set(element, 'name', element.crmName);
                                    });
                                    break;
                                case 'warehouse'://仓库
                                    records.forEach(element => {
                                        this.$set(element, 'name', element.whName);
                                    });
                                    break;
                                case 'product'://加工产品名称（物料名称）
                                    records.forEach(element => {
                                        this.$set(element, 'name', element.inventoryName);
                                    });
                                    break;
                                default:
                                    break;
                            }

                            if(!response.data.records){
                                this.tableData = []
                                const childrenNav = [];
                                officeUserListToTree(records, childrenNav, "0");
                                this.tableData.push(records[0]) ;
                            } else{
                                this.tableData = records;
                            }


                            // const value = this.dynamicData.val;
                            // if (!value) {
                            //     Object.assign(this, {
                            //         searchValue: value,
                            //         viewData: this.tableData
                            //     });
                            //     return false;
                            // }
                            // let expandedKeys = new Array();
                            // //重组tree
                            // let newTree = searchInTreeData(expandedKeys, this.tableData, "title", value);
                            // Object.assign(this, {
                            //     searchValue: value,
                            //     autoExpandParent: true,
                            //     viewData: newTree
                            // });
                        }

                        this.isRun = false;

                        //库存初期默认选择第一个仓库
                        if (defaultRun == 'warehouse') {
                            this.codesName = "warehouseId";
                            this.clickEnter('click', records[0]);
                        }
                    }
                }).catch(error => { });
            }
        },
        showModal () {
            this.tableShow = true;
            this.pageList();
            console.log('col值：', this.dynamicData.code)
            if (this.dynamicData.length > 0) {
                this.codesName = this.dynamicData.code;
                this.boxId = this.dynamicData.code;
            }
            this.$nextTick(() => {
                let w = document.body.clientWidth;//当前可视窗口宽度
                let searchBox = this.$refs.searchWrapper.getBoundingClientRect();
                let searchInput = this.$refs.searchInput.getBoundingClientRect();
                console.log(searchInput, w);
                // console.log('弹出框距离左侧距离：', searchBox.right, w, searchInput)
                if (searchInput.right + 50 >= w) { //右边溢出处理
                    this.$refs.searchWrapper.style.left = -(searchBox.width - searchInput.width) + 'px';
                } else if (searchInput.left < 400) { //左边溢出处理
                    this.$refs.searchWrapper.style.left = 0 + 'px';
                } else {
                    this.$refs.searchWrapper.style.left = - searchInput.width + 'px'
                }
            })
        },
        onclose () {
            this.tableShow = false;
        },
        inputSearch () {
            this.tableShow = true;
            let val = this.dynamicData.val;
            switch (val) {
                case 'supplie'://供应商
                    this.postData.keyWord = this.inputValue;
                    break;
                case 'office'://部门
                    this.postData.officeCode = this.inputValue;
                    break;
                case 'employees'://业务员、请购人、检验
                case 'project'://项目
                case 'currency'://币种
                case 'purchaseType'://采购类型
                case 'saleType'://销售类型
                    this.postData.searchKey = this.inputValue;
                    break;
                case 'crm'://客户名称
                    this.postData.keyWord = this.inputValue;
                    break;
                case 'crmCustomer'://报价单客户名称
                    this.postData.keyWord = this.inputValue;
                    break;
                case 'warehouse'://仓库
                    this.postData.keyWord = this.inputValue;
                    break;
                case 'invoiceType'://发票
                    this.postData.searchKey = this.inputValue;
                case 'product'://加工产品名称（物料名称）
                    this.postData.key = this.inputValue;
                    break;
                case 'accounting'://会计科目
                    this.postData.name = this.inputValue;
                    break;
                case 'stageGroup'://合同阶段组
                    this.postData.code = this.inputValue;
                    break;
                case 'contractType'://合同类型
                    this.postData.code = this.inputValue;
                    break;
                default:
                    break;
            }
            //延迟请求
            if (this.setTime) {
                clearTimeout(this.setTime)
            }
            this.setTime = setTimeout(() => {
                this.pagination.current = 1;
                this.pageList();
            }, 500)
        },
        clickEnter (type, record) {
            //type == 'click' 表示点击表格事件
            let data = {};
            if (type == 'click') {
                data = Object.assign(record, { codesName: this.codesName })
                this.id = record.id;
            } else {
                data = Object.assign(this.tableData[0], { codesName: this.codesName })
                this.id = this.tableData[0].id;
            }
            this.inputValue = data.name;

            console.log(`${this.dynamicData.name}选中的数据：`, data)

            this.$emit('clickItem', data);
            this.$refs.inputRef.blur();
            this.onclose();
        },
        checkSearch () {
            //当前搜索类型
            // supplie      供应商
            // office       部门
            // employees    业务员、请购人、检验
            // project      项目
            // currency     币种
            // purchaseType 采购类型
            // crm          客户名称
            // saleType     销售类型
            // warehouse    仓库
            // despatchType     运输方式
            //departmentstaff   部门员工
            let val = this.dynamicData.val;
            switch (val) {
                case 'departmentstaff'://部门员工
                    this.apiUrl = '/sys/employee/pageSysEmployeeSimpleVo';
                    this.columns = [
                        {
                            title: "工号", dataIndex: "empNo", align: 'center',
                            scopedSlots: {
                                customRender: "empNo",
                            },
                        },
                        {
                            title: "姓名", align: 'center', dataIndex: "empName",
                            scopedSlots: {
                                customRender: "empName",
                            },
                        },
                        {
                            title: "部门", align: 'center', dataIndex: "officeName",
                            scopedSlots: {
                                customRender: "officeName",
                            },
                        }
                    ];

                    this.postData = {
                        'current': this.pagination.current,
                        'size': this.pagination.pageSize,
                        officeId: this.dynamicData.officeId
                    }
                    break;
                case 'crm'://客户
                    this.apiUrl = '/crm/customer/pageForVoucher';
                    this.columns = [
                        { title: "首拼码", dataIndex: "crmSimpleName" },
                        { title: "客户名称", dataIndex: "crmName", ellipsis: true, },
                        // { title: "所属地区", dataIndex: "areaName", ellipsis: true, },
                        // { title: "所属行业", dataIndex: "industry", ellipsis: true, },
                        // { title: "联系地址", dataIndex: "address", ellipsis: true, },
                        // { title: "客户类型", dataIndex: "partnerClassId", ellipsis: true, scopedSlots: { customRender: "partnerClassCustomer" }},
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        isFinance: 1,
                        companyType: 'isCustomer'
                    }
                    break;
                case 'supplie'://供应商
                    this.apiUrl = '/crm/customer/pageForVoucher';
                    this.columns = [
                        { title: "供应商编码", dataIndex: "crmNo", ellipsis: true, width: 100 },
                        { title: "供应商名称", dataIndex: "crmName", ellipsis: true, width: 100 },
                        // { title: "供应商编码", dataIndex: "vendorCode", ellipsis: true, },
                        // { title: "类型", dataIndex: "partnerClassId", scopedSlots: { customRender: "partnerClassId" }, },
                        // { title: "联系地址", dataIndex: "address", ellipsis: true, },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        isFinance: 1,
                        companyType: 'isSupplier'
                    }
                    break;
                case 'contacts'://往来单位
                    this.apiUrl = '/crm/customer/pageForVoucher';
                    this.columns = [
                        // { title: "首拼码", dataIndex: "vendorPym", },
                        { title: "往来单位编码", dataIndex: "crmNo", ellipsis: true, width: 100 },
                        { title: "往来单位名称", dataIndex: "crmName", ellipsis: true, width: 100 },
                        // { title: "类型", dataIndex: "partnerClassId", scopedSlots: { customRender: "partnerClassId" }, },
                        // { title: "联系地址", dataIndex: "address", ellipsis: true, },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        isFinance: 1,
                    }
                    break;
                case 'employees'://业务员、请购人、检验
                    this.apiUrl = '/sysUser/user/page';
                    this.columns = [
                        { title: "所属机构", dataIndex: "officeName", ellipsis: true, scopedSlots: { customRender: "officeName" }, },
                        { title: "姓名", dataIndex: "realName" },
                        // { title: "手机号", dataIndex: "mobile" },
                        // { title: "电子邮箱", dataIndex: "email", ellipsis: true, },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue
                    }
                    break;
                case 'office'://部门
                    this.apiUrl = '/system/office/page';
                    this.columns = [
                        { title: "编码", dataIndex: "officeCode", width: 80 },
                        { title: "机构名称", dataIndex: "officeName", ellipsis: true, scopedSlots: { customRender: "officeName" }, },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        officeCode: this.inputValue
                    }
                    break;
                case 'project'://项目
                    this.apiUrl = '/erp/project/pageList';
                    this.columns = [
                        { title: "项目编码", dataIndex: "code" },
                        { title: "项目名称", dataIndex: "name" },
                        { title: "所属部门", dataIndex: "department" },
                        { title: "负责人", dataIndex: "liablePersonNames" },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue
                    }
                    break;
                case 'currency'://币种
                    this.apiUrl = '/erp/currency/pageList';
                    this.columns = [
                        // { title: "编码", dataIndex: "code" },
                        { title: "币名", dataIndex: "name" },
                        { title: "币符号", dataIndex: "currencySign" },
                        // {
                        //     title: "折算方式",
                        //     dataIndex: "calDirection",
                        //     customRender: (text, row, index) => {
                        //         return text == 1 ? "原币*汇率=本位币" : "原币/汇率=本位币";
                        //     },
                        //     ellipsis: true,
                        // },
                        // {
                        //     title: "汇率设置方式",
                        //     dataIndex: "exChangeRateType",
                        //     customRender: (text, row, index) => {
                        //         return text == 1 ? "日汇率" : "月汇率";
                        //     }
                        // }
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue
                    }
                    break;
                case 'purchaseType'://采购类型
                    this.apiUrl = '/erp/purchaseType/pageList';
                    this.columns = [
                        { title: "编码", dataIndex: "code" },
                        { title: "名称", dataIndex: "name" },
                        { title: "入库类别", dataIndex: "styleName" }
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue
                    }
                    break;
                case 'saleType'://销售类型
                    this.apiUrl = '/erp/saleType/pageList';
                    this.columns = [
                        { title: "销售类型编码", dataIndex: "code" },
                        { title: "销售类型名称", dataIndex: "name" },
                        { title: "出库类别", dataIndex: "styleName" },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue
                    }
                    break;
                case 'processRoute'://工艺路线
                    this.apiUrl = '/erp/processRoute/getList';
                    this.columns = [
                        { title: "编码", dataIndex: "code" },
                        { title: "名称", dataIndex: "name" },
                        { title: "版本号", dataIndex: "versionCode" }
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                        status: 1,            //状态1:正常 0停用
                        examineStatus: 1,    //审核状态1:已审 0:未审
                    }
                    break;
                case 'crmCustomer'://报价单客户
                    this.apiUrl = '/crm/customer/pageForVoucher';
                    this.columns = [
                        { title: "首拼码", dataIndex: "crmSimpleName" },
                        { title: "客户名称", dataIndex: "crmName", ellipsis: true, },
                        // { title: "所属地区", dataIndex: "areaName", ellipsis: true, },
                        // { title: "所属行业", dataIndex: "industry", ellipsis: true, },
                        // { title: "联系地址", dataIndex: "address", ellipsis: true, },
                        // { title: "客户类型", dataIndex: "partnerClassId", ellipsis: true, scopedSlots: { customRender: "partnerClassCustomer" }},
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                    }
                    break;
                case 'warehouse'://仓库
                    let path = this.$route.path;
                    if (path == '/inventory/bills/purchaseIn' || path == '/inventory/bills/productIn' || path == '/inventory/bills/saleOut' || path == '/inventory/bills/materialOut') {
                        //表示是库存管理里的采购入库
                        this.apiUrl = '/in/warehouse/listMyOperationInWarehouses'
                    } else {
                        this.apiUrl = '/in/warehouse/pageList';
                    }

                    this.columns = [
                        { title: "仓库编码", dataIndex: "whCode", width: 80 },
                        { title: "仓库名称", dataIndex: "whName", ellipsis: true, },
                        // { title: "负责人", dataIndex: "whPerson", ellipsis: true, },
                        // { title: "电话", dataIndex: "whTelephone", ellipsis: true, },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        keyWord: this.inputValue,
                    }
                    break;
                case 'despatchType'://运输
                    this.apiUrl = '/erp/despatchType/pageList';
                    this.columns = [
                        { title: "发运方式编码", dataIndex: "code" },
                        { title: "发运方式名称", dataIndex: "name" }
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                    }
                    break;
                case 'invoiceType'://发票类型
                    this.apiUrl = '/erp/invoiceType/pageList';
                    this.columns = [
                        { title: "发票类型编码", dataIndex: "code" },
                        { title: "发票类型名称", dataIndex: "name" },
                        {
                            title: "方向",
                            dataIndex: "type",
                            customRender: (text) => {
                                return <span>{text == 1 ? "正发票" : "负发票"}</span>;
                            },
                        },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        type: this.changeInvoiceType,
                    }
                    break;
                case 'accounting'://会计科目
                    this.apiUrl = '/erp/accounting/page';
                    this.columns = [
                        {
                            title: "科目编码",
                            dataIndex: "code",
                            align: "left",
                            width: 100
                        },
                        {
                            title: "科目名称",
                            dataIndex: "name",
                            align: "left",
                            width: 100,
                        }, {
                            title: "科目类型",
                            dataIndex: "accountingTypeName",
                            align: "left",
                            width: 100,
                        }, {
                            title: "余额方向",
                            dataIndex: "dcDirection",
                            align: "left",
                            width: 100,
                            customRender: (text, row, index) => {
                                if (text) {
                                    return text == 1 ? "借方" : "贷方";
                                }
                            }
                        }
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        // searchKey: this.inputValue
                        name: this.inputValue,
                    }
                    break;
                // case 'ReceiveRdStyle': //入库类别
                //     this.apiUrl = '/in/rdStyle/pageStyleList';
                //     this.columns = [
                //         { title: "出入库类别编码", dataIndex: "code", key: "code" },
                //         { title: "出入库类别名称", dataIndex: "name", key: "name" },
                //         {
                //             title: "类别", dataIndex: "type", key: "type",
                //             customRender: (text) => {
                //                 return text == 1 ? '收' : '发';
                //             }
                //         }
                //     ];
                //     this.postData = {
                //         current: this.pagination.current,
                //         size: this.pagination.pageSize,
                //     }
                //     break;
                case 'warehouseTypeIn'://入库类别
                    this.apiUrl = '/in/rdStyle/pageStyleList';
                    this.columns = [
                        { title: "类别编码", dataIndex: "code", key: "code", align: "left", width: 100 },
                        { title: "类别名称", dataIndex: "name", key: "name", align: "left", width: 100 },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                        type: 1,
                    }
                    break;
                case 'warehouseTypeOut'://出库类别
                    this.apiUrl = '/in/rdStyle/pageStyleList';
                    this.columns = [
                        { title: "类别编码", dataIndex: "code", key: "code", align: "left", width: 100 },
                        { title: "类别名称", dataIndex: "name", key: "name", align: "left", width: 100 },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                        type: 2,
                    }
                    break;
                case 'product'://加工产品名称
                    this.apiUrl = '/in/inventory/getList';
                    this.columns = [
                        { title: "物料编码", dataIndex: "inventoryCode", align: 'left', width: 120 },
                        { title: "物料名称", dataIndex: "inventoryName", align: 'left', width: 120 },
                        { title: "规格型号", dataIndex: "inventorySpecification", align: 'left', width: 80 },
                        {
                            title: "物料属性", dataIndex: "inventoryAttribute", width: 240, customRender: (text, record, index) => {
                                let attribute = [];
                                if (record.isPurchasing) {
                                    attribute.push('允许外购');
                                }
                                if (record.isForSale) {
                                    attribute.push('允许销售');
                                }
                                if (record.isMadeSelf) {
                                    attribute.push('允许自制');
                                }
                                if (record.isMaterial) {
                                    attribute.push('允许生产耗用');
                                }
                                if (record.isLaborCost) {
                                    attribute.push('允许劳务费用');
                                }
                                if (record.isSuite) {
                                    attribute.push('允许成套件');
                                }
                                if (record.isMadeRequest) {
                                    attribute.push('允许委外');
                                }
                                if (record.isInventedKey) {
                                    attribute.push('允许虚拟件');
                                }
                                return attribute.join('，');
                            }, ellipsis: true
                        },
                        { title: "计量方式", dataIndex: "unitType", width: 80, align: 'center', }
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                    }
                    break;
                case 'inventoryCategory'://存货分类
                    this.apiUrl = '/in/inventoryCategory/getInventoryCategoryList';
                    this.columns = [
                        { title: "类别编码", dataIndex: "code", key: "code", align: "left", width: 100 },
                        { title: "类别名称", dataIndex: "name", key: "name", align: "left", width: 100 },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                    }
                    break;
                case 'contractType'://合同类型
                    this.apiUrl = '/cm/contractType/getList';
                    this.columns = [
                        { title: "类别编码", dataIndex: "code", key: "code", align: "left", width: 100 },
                        { title: "类别名称", dataIndex: "name", key: "name", align: "left", width: 100 },
                        {
                            title: "收付计划方向",
                            dataIndex: "planDirection",
                            align: "left",
                            width: 100,
                            customRender: (text, row, index) => {
                                if (text) {
                                    return text == 1 ? "收" : text == 2 ? "付" : text == 3 ? "其他" : '';
                                }
                            }
                        }
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                    }
                    break;
                case 'stageGroup'://合同阶段组
                    this.apiUrl = '/cm/stageGroup/getList';
                    this.columns = [
                        { title: "阶段编码", dataIndex: "code", key: "code", align: "left", width: 100 },
                        { title: "阶段名称", dataIndex: "name", key: "name", align: "left", width: 100 },
                    ];
                    this.postData = {
                        current: this.pagination.current,
                        size: this.pagination.pageSize,
                        searchKey: this.inputValue,
                    }
                    break;
                default:
                    break;
            }
        }
    }
}
</script>
<style lang="less">
    .all-search-wrapper {
        .inputClass {
            width: 100px;
        }
        .search-wrapper {
            max-height: 350px;
            box-shadow: 2px 2px 10px 2px #e0e0e0;
            position: absolute;
            left: -170px;
            z-index: 100;
            border: 1px solid #a7abb0;
            width: 500px;
        }
        // .ant-table-wrapper .ant-table-placeholder {
        //     position: static !important;
        //     top: 0;
        // }
        .ant-table-wrapper {
            background: #eee;
        }
        .ant-table-tbody {
            cursor: pointer;
        }
    }
</style>